const path = require("path");

module.exports = {
  resolve: {
    extensions: [".tsx", ".js", ".json", ".jsx", ".css", ".scss", ".ts"],
    alias: {
      "@src": path.join(__dirname, `../src/`),
      "@service": path.join(__dirname, "../src/service"),
    },
  },
  module: {
    rules: [
      {
        test: /\.jsx?$/, // jsx/js文件的正则
        // exclude: /node_modules/, // 排除 node_modules 文件夹
        exclude: /node_modules(\\|\/)(?!(@andrew-cube(\\|\/)react))/,
        use: "babel-loader?cacheDirectory=true",
      },
      {
        test: /\.(css|scss)$/,
        use: [
          "style-loader",
          "css-loader",
          {
            loader: "sass-loader",
            options: {
              implementation: require("sass"),
            },
          },
        ],
      },
      {
        test: /\.(ico|png|jpe?g|gif|eot|svg|ttf|woff|woff2)$/,
        use: [
          {
            loader: "url-loader",
            options: {
              limit: 81920,
              outputPath: "static/imgs/",
              name: "[name].[hash:7].[ext]",
            },
          },
        ],
      },
    ],
  },
};
